﻿using System;
using System.Linq;
using SharePointUtilitiesForDevelopers.Mapper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SharePointUtilitiesForDevelopers.Tests.Mapper
{
    /// <summary>
    ///Test class for <see cref="SharePointFieldMapper"/>.
    ///</summary>
    [TestClass]
    public class SharePointFieldMapperTest
    {
        [TestMethod]
        public void MapList_returns_correct_list()
        {
            var from = ServiceResponseTestHelper.LoadXml("GetList.xml");
            var target = new SharePointFieldMapper();
            var result = target.MapList(from);
            Console.WriteLine("{0} items", result.Count());
            Assert.IsTrue(result.Count() > 0);
        }

        [TestMethod]
        public void Map_returns_correct_object()
        {
            var from = ServiceResponseTestHelper.GetFirstElement("GetList.xml", "Field");
            var target = new SharePointFieldMapper();
            var result = target.Map(from);
            Assert.IsTrue(result != null);
        }

    }
}